<?php
namespace app\admin\model;

use think\Model;

class ProClassifyModel extends Model
{
	// 确定链接表名
    protected $name = 'product_classify';

    /**
	 * [获取所有产品分类]
     */
    public function getClassifyList(){
    	return $this->where($this->whereCansee())->select();
    }

    /**
	 * [添加产品分类]
     */
    public function addClassify($param){
    	if($this->insert($param)){
    		return ['code'=>1,'msg'=>'添加成功'];
    	}else{
    		return ['code'=>0,'msg'=>'添加失败'];
    	}
    }

    /**
	 * [编辑产品分类]
     */
    public function editClassify($param){
    	try{
    		$this->where('id',$param['id'])->update($param);
    		return ['code'=>1,'msg'=>'编辑成功'];
    	}catch(Exception $e){
    		return ['code'=>0,'msg'=>'编辑失败'.$e->getMessage()];
    	}
    }

    /**
	 * [删除学校/专业]
     */
    public function delClassify($param){
    	if($this->where('id',$param)->delete()){
    		return ['code'=>1,'msg'=>'删除成功'];
    	}else{
    		return ['code'=>0,'msg'=>'删除失败'];
    	}
    }
}